package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.CheckGroupService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/checkGroup")
public class CheckGroupController {

    @Reference
    private CheckGroupService checkGroupService;

    @RequestMapping("/add")
    public Result add(@RequestBody CheckGroup checkGroup, Integer[] checkitemIds){
        return checkGroupService.add(checkGroup,checkitemIds);
    }

    @RequestMapping("/selectByPage")
    public PageResult selectByPage(@RequestBody QueryPageBean queryPageBean){
       return checkGroupService.selectByPage(queryPageBean);
    }

    @RequestMapping("/findById")
    public Integer[] findById(int id){
       return checkGroupService.findById(id);
    }

    @RequestMapping("/update")
    public Result update(@RequestBody CheckGroup checkGroup,Integer[] checkitemIds){
        return checkGroupService.update(checkGroup,checkitemIds);
    }

    @RequestMapping("/delete")
    public Result delete(int id){
      return checkGroupService.deleteOne(id);
    }

    @RequestMapping("/findAll")
    public List<CheckGroup> findAll(){
       return checkGroupService.findAll();
    }
}
